﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SDT.Mobile.Models.LinkViewModel>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<div class="b_link">
<select id="ddlLink">
<option value="">-- Chọn danh mục --</option>
<% if (Model != null) { %>
	<%foreach (var item in Model.ProductTypes)
   {
       var link ="/"+ TextHelper.ToUrlFriendly(item.Name);
       link += "/p/" + item.ID;
   %>
		<option value="<%= link %>"><%= item.Name %></option>
	<% }} %>
	
	<%var catas = Model.ArticleCategorys.Where(e => e.ActiveYN == true).ToList();
   foreach (var item in catas)
   {
       var link = ActionImageHelpers.GetLink(item.Name, item.Name, "article", "index", new Dictionary<string, object>() { { "id", item.ID } }, false, string.Empty, false);
       if (item.ArticleCategories.Count > 0)
       {  
   %>
		<option value="<%= link %>"><%= item.Name%></option>
	<% }
       else { %>
       <option value="<%= link %>" style="padding-left:10px"><%= item.Name%></option>
       <%}
   } %>
   
	
</select>
<script type="text/javascript">
    $(document).ready(function() {
        $('#ddlLink').change(function() {
            var url = $('#ddlLink').val() == "" ? 0 : $('#ddlLink').val();
            if (url != "") {
                window.location=url;
            };
        });
    });
</script>
</div>
